Use trusted publishing for PyPI releases - #193
Conversation
Signed-off-by: Jacob Yundt <me@jyundt.com>
| 1. Update ``CHANGELOG.md``, ``setup.py``, and ``src/redfish/__init__.py`` with | ||
| the new version in a pull request. | ||
| 2. Merge the pull request. | ||
| 3. Create a GitHub release from the merged commit with the version as its tag. |
There was a problem hiding this comment.
Could we keep this its own workflow (thus preserving the removed portions in the Release and Publish flow). I like the ease of having a push-button approach to updating versions/changelogs.
There was a problem hiding this comment.
Implemented in ad19d8c. The new prepare-release.yml workflow preserves the existing version, changelog and tagged-release automation. It then dispatches main.yml at the new tag.
The publishing workflow verifies the published release and version metadata, builds without publishing credentials and waits for approval on the pypi environment before publishing through OIDC.
The remaining setup step is to configure the repository’s pypi environment with a required reviewer.
|
@mraineri It seems the current hesitation stems from a reluctance to lose the convenience of the original "push-button" automation for managing versions and changelogs. However, GitHub Actions can actually deliver the best of both worlds—preserving that ease of use while fully complying with PyPI's strict OIDC security requirements. We can split this into a seamless two-step automated workflow:
By separating the repository automation from the secure publication phase, we can maintain the exact single-button convenience the maintainers prefer, while granting Home Assistant the publicly verifiable supply chain transparency it requires. What do you think about this approach? |
|
Recap of quick chat with @mraineri I’ll split this into two workflows:
I’ll put the PyPI publishing job behind approval on the |
Signed-off-by: Jacob Yundt <me@jyundt.com>
|
Approving and merging out of cycle to test out the flow |
Summary
setup.py,redfish.__version__andCHANGELOG.mdpypiGitHub environmentMotivation
The current release workflow updates the version and changelog, pushes those changes, creates the GitHub release, builds the package and publishes it with a stored
PYPI_API_TOKEN. Although the workflow is public, packages published this way do not include PyPI provenance attestations.This change keeps the existing push-button release preparation. The manually dispatched workflow still accepts the version and changelog entries, updates the release metadata, pushes the changes to
mainand creates the tagged GitHub release.PyPI publication is handled separately. After creating the release, the preparation workflow dispatches
main.ymlat the new tag. The publishing workflow verifies that it is running from a published release tag, checks the package and changelog versions, builds the distributions without publishing credentials and transfers only those distributions to the publishing job.The publishing job waits for approval through the protected
pypiGitHub environment. Once approved, it authenticates to PyPI using a short-lived OIDC credential and uploads provenance attestations with the distributions.This was prompted by the dependency-transparency review for the downstream Home Assistant Redfish integration.
Closes #194.
Maintainer setup required
Before the first release using this workflow:
pypienvironment in this GitHub repository and configure at least one required reviewer.redfishproject, confirm that the GitHub Trusted Publisher is configured with:DMTFpython-redfish-librarymain.ymlpypiPYPI_API_TOKENrepository secret.This draft should not be marked ready until the protected GitHub environment and PyPI Trusted Publisher have both been confirmed.
Validation
actionlintwith ShellCheck for both workflows: passedzizmoraudit for both workflows: no findingstwine checkfor both distributions: passedNo GitHub release or PyPI publication was triggered during validation.
The existing
tox -e pep8target continues to report pre-existing formatting errors in files untouched by this change.